<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="adminCommon::common-header"></head>
<body class="sb-nav-fixed">
<nav th:replace="adminCommon::common-navbar"></nav>
<div id="layoutSidenav">
    <div th:replace="adminCommon::common-sidenav"></div>

    <div id="layoutSidenav_content">
        <main>
            <div class="container-fluid px-4">
                <h2 class="mt-4">Add Course</h2>

                <ol class="breadcrumb mb-4">
                    <li class="breadcrumb-item"><a th:href="@{/toAdminMain}">HomePage</a></li>
                    <li class="breadcrumb-item"><a th:href="@{/class/selClass}">Course Management</a></li>
                    <li class="breadcrumb-item active">Add Course</li>
                </ol>

                <div class="card mb-4">

                    <form th:action="@{/class/addClass}" method="post" name="addForm"
                          onsubmit="return beforeSubmit(this)">
                        <table class="table table-hover">
                            <tr>
                                <td text-align="center">Code：</td>
                                <td><input type="text" class="form-control" placeholder="4 digit number" name="classId"></td>
                            </tr>

                            <tr>
                                <td text-align="center">Name：</td>
                                <td><input type="text" class="form-control" placeholder="Course Title" name="className">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">Time：</td>
                                <td><input type="text" class="form-control" placeholder="xxxx year xx month xx day 00:00" name="classBegin">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">Period：</td>
                                <td><input type="text" class="form-control" placeholder="xx minutes" name="classTime">
                                </td>
                            </tr>
                            <tr>
                                <td text-align="center">Coach‘s Name：</td>
                                <td><input type="text" class="form-control" placeholder="Coach Name" name="coach">
                                </td>
                            </tr>
                        </table>
                        <div style="text-align:center;margin-top:20px;margin-bottom:20px">
                            <input type="submit" class="btn btn-outline-success" value="添加">
                        </div>
                    </form>
                </div>
            </div>
        </main>
        <footer th:replace="adminCommon::common-footer"></footer>
    </div>
</div>

<div th:include="adminCommon::common-scripts"></div>
<script type="text/javascript">
    function beforeSubmit(addForm) {
    if (addForm.classId.value == "") {
        alert("Please enter your course number!");
        return false;
    }
    if (addForm.className.value == "") {
        alert("Please enter the course name!");
        return false;
    }
    if (addForm.classBegin.value == "") {
        alert("Please enter the course time!");
        return false;
    }
    if (addForm.classTime.value == "") {
        alert("Please enter the course duration!");
        return false;
    }
    if (addForm.coach.value == "") {
        alert("Please enter the coach!");
        return false;
    }
    return true;
}
</script>
</body>
</html>
